/**
*      author: Y_Yao
*      created: 2024-09-28 13:57:53
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 9;
int a[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n = 0;
    cin >> n;
    int even = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        if( i >= 1 && i <= n-2 && a[i] % 2 == 0) even++;
    }

    if(even == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    LL ret = 0;
    for(int i = 1;i < n - 1;i++)
    {
        if(a[i] % 2 == 0)
        {
            ret += a[i] / 2;
        }
        else
        {
            ret += (a[i] + 1) / 2;
        }
    }
    cout << ret << endl;
    return 0;
}